<?php



include_once("codelibrary/inc/variables.php");





include_once("customersession.php");



//include_once("codelibrary/inc/functions.php");

include_once("codelibrary/inc/appointment.php");

include_once("codelibrary/calendar/showcal.php");





// include('includes/header.php');



$business_id = $_SESSION['business_id'];



$today_date = date("Y-m-d");

$date_passed = $today_date;

$displayed_day = date("d");

$displayed_month = date("n");

$displayed_year = date("Y");

$staff_id = $_GET['staff_id'];



$stamp = $_GET['stamp'];



if($stamp == "")

$stamp = mktime();



$appid = $_GET['appid'];

if($appid!='') {

	$res= getAppointments($stamp,$appid);

	$obj = mysql_fetch_object($res);



	if($obj->starttime=='') {

		die('Error: No appointment found');

	}

}



$arr = getOfficeHours();

$interval = getAppointmentTime();



?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

<html dir="LTR" lang="en">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<title>Online Appointment</title>

<base >

<link rel="stylesheet" type="text/css" href="stylesheet.css">

<title>Staff Management</title>

</head>

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">

<script src="codelibrary/js/scripts.js" type="text/javascript"></script>

<script src="codelibrary/js/finalize-appointment.js" type="text/javascript"></script>

<script src="codelibrary/js/prototype.js" type="text/javascript"></script>

<table cellpadding="0" cellspacing="0" border="0"><tr>

  <td style="background:url(images/top.gif) repeat-x top; ">

<table cellpadding="0" cellspacing="0" border="0" style="width:764px" align="center"> 

	<tr>

		<td>

			<table cellpadding="0" cellspacing="0" border="0" style="height:57">

				<tr>

					<td height="57">

					<? //html_header(); ?>

					</td>

				</tr>

			</table>

		</td>

	</tr>

	<tr>

		<td>

<table border="0" width="105%" cellspacing="0" cellpadding="0">

  <tr>

    <td valign="top" class="col_left">



<table border="0"cellspacing="0" cellpadding="0" class="box_width_left">

	<tr><td width="100%">

		<table border="0" cellspacing="0" cellpadding="0">

<tr><td>



<table border="0" width="100%" cellspacing="0" cellpadding="0" class="">

  <tr>

    <td>

    <table border="0" width="100%" cellspacing="0" cellpadding="0"  class="" height="91">

  <tr>

    <td align="center" height="91">

    <img border="0" src="images/logo.jpg" width="208" height="86"></td>

  </tr>

</table>

</td>

  </tr>

</table>

</td></tr>





          <tr>

            <td>

<table border="0" width="100%" cellspacing="0" cellpadding="0"  class="box_header_txt" height="48">

  <tr>

    <td style="background-image: url(images/1_bg2-2.gif)" height="1">

      <p style="margin-top: 16"> </td>

  </tr>

</table>

<table border="0" width="100%" cellspacing="0" cellpadding="0"   style="border-bottom:12px solid #ffffff;">

  <tr>

    <td>

    <table border="0" width="100%" cellspacing="0" cellpadding="0"  style="margin-bottom:0px;background:#7C7C7C url(images/1_line.gif) no-repeat left bottom;" >

  <tr>

    <td  style="padding:3px 16px 8px 14px;">

                                          <table width="100%" border="0">



                                            <tr>

                                              <td><?php

								    showStaffSelect($staff_id,"customer-make-appointment.php")

								 ?>&nbsp;<br>&nbsp;                                              </td>
                                            </tr>

											

                                            <tr>

                                              <td><?php

              showCalendar($staff_id,"customer-make-appointment.php");

          ?>

		  <script>

		  document.getElementById('selectstaff').value='<?= $staff_id ?>';

		  </script>                                              </td>
                                            </tr>
                                            <tr>
                                              <td>&nbsp;</td>
                                            </tr>
                                            <tr>
                                              <td><? include_once('customer-menu.php'); ?></td>
                                            </tr>
                                          </table>

    </td>

  </tr>

</table>

</td>

  </tr>

</table>

            </td>

          </tr>





          <tr>

            <td class="">&nbsp;

</td>

          </tr>



		</table>

	</td>

	<td><img src="images/spacer.gif" border="0" alt="" width="15" height="1"></td></tr>

</table>



    </td>



    <td width="100%" valign="top">

<table border="0" width="100%" cellspacing="0" cellpadding="0"  class="cont_header_txt">

  <tr>

    <td>

			<table border="0" cellpadding="0" cellspacing="0" bgcolor="#EAEAEA" class="cont_header_txt">

				<tr>

					<td><img src="images/1_q1.gif" border="0" alt="" width="45" height="39"></td>

					<td style="width:100%">Finalize Appointments</td>

					<td><img src="images/1_q2.gif" border="0" alt="" width="10" height="39"></td>

				</tr>

			</table>										 

			</td>

  </tr>

</table>





						

						<script type="text/javascript" src="codelibrary/js/calendarDateInput.js"></script>

						<table cellpadding="0" cellspacing="0" border="0" style="border:0px solid #DEDEDE; border-width:0px 1px 0px 1px;">

                          <tr>

                            <td style="background:#ffffff;border:0px solid #ffffff; border-width:18px 5px 10px 5px;"><!-- new_products //-->

                                <table border="0" width="" cellspacing="0" cellpadding="0" class="box_width_cont product">

                                  <tr>

                                    <td ><div class="pageHeading"><? print date("l F d, Y", $stamp);

									?></div></td>

                                  </tr>

                                  <tr>

                                    <td align="right" ><input type="button" id="finalize" name="finalize" value="Finalize Appointment" class="button" onClick="return validate(document.finalizeFrm)"/></td>

                                  </tr>

                                  <tr>

                                    <td><div id="error"><h3>Following Errors has occured :- </h3>

									<div id="errmsgs">

										This is the error.

									</div>

									</div></td>

                                  </tr>

								  <tr><td>

								

								  <div id="formcontent">

								    <table width="100%" border="0" cellpadding="1" cellspacing="1" bgcolor="#FF6A21">

                                    <form name="finalizeFrm" onSubmit="reutrn validate(this)">

									  <tr>

                                        <td width="15%" bgcolor="#FFFFFF" class="tablecells">Service</td>

                                        <td width="27%" bgcolor="#FFFFFF" class="tablecells"><? serviceListForm($_REQUEST['staff_id']); ?></td>

                                        <td width="24%" bgcolor="#FFFFFF" class="tablecells">With</td>

                                        <td width="34%" bgcolor="#FFFFFF" class="tablecells"><? staffListForm($_GET['staff_id']); ?></td>
                                      </tr>

                                      <tr>

                                        <td bgcolor="#FFFFFF" class="tablecells">Date </td>

                                        <td bgcolor="#FFFFFF" class="tablecells"><script>DateInput('apptdate', true, 'YYYY-MM-DD'<? if($stamp!="") { echo ",'".date("Y-m-d",$stamp)."'"; } ?>)</script></td>

                                        <td bgcolor="#FFFFFF" class="tablecells">Start Time </td>

                                        <td bgcolor="#FFFFFF" class="tablecells"><? startTimeListForm($arr, $interval, $stamp); ?></td>
                                      </tr>

                                      <tr>

                                        <td bgcolor="#FFFFFF" class="tablecells">Duration</td>

                                        <td bgcolor="#FFFFFF" class="tablecells"><? listDurationForm($interval); ?></td>

                                        <td bgcolor="#FFFFFF" class="tablecells">Status</td>

                                        <td bgcolor="#FFFFFF" class="tablecells"><? statusListForm($as_id); ?></td>
                                      </tr>

                                      <tr>

                                        <td bgcolor="#FFFFFF" class="tablecells">Cost</td>

                                        <td bgcolor="#FFFFFF" class="tablecells"><input name="cost" type="text" id="cost" readonly/></td>

                                        <td bgcolor="#FFFFFF" class="tablecells">Tip</td>

                                        <td bgcolor="#FFFFFF" class="tablecells"><input name="tip" type="text" id="tip" /></td>
                                      </tr>

                                      <tr>
                                        <td bgcolor="#FFFFFF" class="tablecells">&nbsp;</td>
                                        <td bgcolor="#FFFFFF" class="tablecells">&nbsp;</td>
                                        <td bgcolor="#FFFFFF" class="tablecells">&nbsp;</td>
                                        <td bgcolor="#FFFFFF" class="tablecells">&nbsp;</td>
                                      </tr>
                                      <tr>

                                        <td bgcolor="#FFFFFF" class="tablecells">Special Instructions for Staff </td>

                                        <td colspan="3" bgcolor="#FFFFFF" class="tablecells"><textarea name="specialinstruction" id="specialinstruction"></textarea></td>
                                      </tr>



									  <input type="hidden" name="appt_id" id="appt_id" value="<?=$obj->appt_id?>" />
										<input type="hidden" name="customer_id" id="customer_id" value="<?=$_SESSION['customer_id']?>" />
										<input type="hidden" name="staffemailstatus" id="staffemailstatus" value="1" />
										<input type="hidden" name="customeremailstatus" id="customeremailstatus" value="1" />
									  </form>
                                    </table>

									</div>



</td></tr>

                                </table>

                              <table border="0" cellspacing="0" cellpadding="0" align="center" class="box_width_cont product">

                                  <tr>

                                    <td><div id="loading">Loading...</div>

									<div id="apptadded"><span id="apptmsg">Appointment Added Successfully</span><br/>Back to <a href="customer-make-appointment.php?stamp=<?=$stamp?>">Home</a></div></td>

                                  </tr>

                              </table></td>

                          </tr>

                        </table>

						

						

						<table cellpadding="0" cellspacing="0" border="0">

							<tr>

								<td><img src="images/1_q4.gif" border="0" alt="" width="10" height="10"></td>

								<td style="width:100%; background-image:url(images/1_li1.gif)"></td>

								<td><img src="images/1_q3.gif" border="0" alt="" width="10" height="10"></td>

							</tr>

						</table>

						





		

		

		</td>



    <td class="col_right">



<table border="0"cellspacing="0" cellpadding="0" class="box_width_right">

	<tr><td></td>

		<td width="100%">

			<table border="0" cellspacing="0" cellpadding="0">

				<tr><td></td></tr>

			</table>

		</td>

	</tr>

</table>





    </td>

  </tr>

</table>







		</td>

	</tr>

	<tr>

		<td>

			<table cellpadding="0" cellspacing="0" border="0" style="height:98px; background-image:url(images/bot.gif)">

				<tr>

					<td>

						<table cellpadding="0" cellspacing="0" border="0" class="footer">

							<tr>									

								<td height="77"><img src="images/spacer.gif" border="0" alt="" width="25" height="1"></td>				

								<td style="width:207px"><br style="line-height:49px"><img src="images/p1.gif" border="0" alt="" width="145" height="24"><br></td>

							  <td style="width:532px">&nbsp;</td>

							</tr>

						</table>

					</td>

				</tr>

			</table>

		</td>

	</tr>

</table></td></tr></table>

<table border="0" width="100%" cellspacing="0" cellpadding="0">

  <tr>

    <td align="center"></td>

  </tr>

</table>

<script>

<? 

if($obj->starttime!='') {

$fields = array('customer_id','staff_id','service_id','duration','apptstatus','cost','tip','customernotes','specialinstruction', 'apptnotes');

	foreach($fields as $f) {

		echo '$("'.$f.'").value = "'.$obj->$f.'";'."\n";

	}



}

?>

$('customeremailstatus').checked = <?=($obj->customeremailstatus == "1") ? 'true':'false'?>;

$('staffemailstatus').checked = <?=($obj->staffemailstatus == "1") ? 'true':'false'?>;

</script>



</body>



</html>